import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

// 引入模块路由
import billRoutes from './modules/bill'
import accountRoutes from './modules/account'
import assetsRoutes from './modules/assets'
// import investmentRoutes from './modules/investment'
import debetRoutes from './modules/debet'

// 主界面布局
import Layout from '@/layout/index.vue'
import Home from '@/views/home/index.vue'
import Login from '@/views/login/index.vue'

// 常规路由
export const constantRoutes = [
  {
    path: '/login',
    component: Login,
    hidden: true
  },
  {
    path: '/',
    redirect: '/home',
    component: Layout,
    children: [
      {
        path: '/home',
        component: Home,
        meta: {
          title: '系统首页',
          icon: 'HomeFilled'
        }
      }
    ]
  }
]

// 整合模块路由
export const asyncRoutes = [
  billRoutes,
  assetsRoutes,
  // investmentRoutes,
  debetRoutes,
  accountRoutes
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [...constantRoutes, ...asyncRoutes]
})

export default router